package com.daka.entity;

import com.daka.tools.DateUtil;
import lombok.Data;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.type.Alias;

import java.text.ParseException;
import java.util.Date;

@Data
@ToString
@Alias(value = "U_VOLUNTEER_WELFARE")
@SuppressWarnings("unused")
@Slf4j
public class VolunteerWelfare {
    /**
     * .
     */
    private Long id;

    /**
     * .
     */
    private String androidPackage;

    /**
     * .
     */
    private String androidUrl;

    /**
     * .
     */
    private Date createTime;

    /**
     * .
     */
    private String endDay;

    /**
     * .
     */
    private String img;

    /**
     * .
     */
    private Integer integral;

    /**
     * .
     */
    private String iosAddres;

    /**
     * .
     */
    private String memberCode;

    /**
     * .
     */
    private Float price;

    /**
     * .
     */
    private String specialDemo;

    /**
     * .
     */
    private String startDay;

    /**
     * .
     */
    private Integer times;

    /**
     * .
     */
    private String useAndroid;

    /**
     * .
     */
    private String useDemo;

    /**
     * .
     */
    private String useIos;

    /**
     * .
     */
    private String useWeb;

    /**
     * .
     */
    private String webAddress;

    /**
     * .
     */
    private String name;

    public static VolunteerWelfare build(WelfareOrder welfareOrder,String memberCode){
        VolunteerWelfare volunteerWelfare = new VolunteerWelfare();

        Date date;
        try {
            date = DateUtil.str2Date(welfareOrder.getCreatetime(),DateUtil.DATETIME_YYYY_MM_DD_HH_MM_SS);
        } catch (Exception e) {
            date = new Date();
            log.error("===============dakaqi============== Date Format Error! VolunteerWelfare MemberCode : " + memberCode + "  welfare " + welfareOrder.getWelfare() );
        }

        volunteerWelfare.setCreateTime(date);
        volunteerWelfare.setAndroidPackage(welfareOrder.getAndroidpackage());
        volunteerWelfare.setAndroidUrl(welfareOrder.getAndroidurl());
        volunteerWelfare.setEndDay(welfareOrder.getEndday());
        volunteerWelfare.setImg(welfareOrder.getImg());
        volunteerWelfare.setIntegral(welfareOrder.getIntegral());
        volunteerWelfare.setIosAddres(welfareOrder.getIosAddress());
        volunteerWelfare.setMemberCode(memberCode);
        volunteerWelfare.setName(welfareOrder.getName());
        volunteerWelfare.setPrice(welfareOrder.getPrice());
        volunteerWelfare.setSpecialDemo(welfareOrder.getSpecialDemo());
        volunteerWelfare.setStartDay(welfareOrder.getStartday());
        volunteerWelfare.setTimes(0);
        volunteerWelfare.setUseAndroid(welfareOrder.getUseAndroid().toString());
        volunteerWelfare.setUseDemo(welfareOrder.getUseDemo());
        volunteerWelfare.setUseIos(welfareOrder.getUseIos().toString());
        volunteerWelfare.setUseWeb(null);
        volunteerWelfare.setWebAddress(null);

        return volunteerWelfare;
    }
}